package com.ssyx.acl.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ssyx.acl.mapper.AdminMapper;
import com.ssyx.acl.service.AdminService;
import com.ssyx.model.acl.Admin;
import com.ssyx.vo.acl.AdminQueryVo;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * ClassName:AdminService
 * Description:
 *
 * @Author kay
 * @Create 2024/4/23 22:14
 * @Version 1.0
 */
@Service
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin>
        implements AdminService {

    //获取管理用户分页列表
    @Override
    public IPage<Admin> getAdminPage(Page<Admin> pageParam, AdminQueryVo adminQueryVo) {
        String name = adminQueryVo.getName();
        String username = adminQueryVo.getUsername();
        LambdaQueryWrapper<Admin> wrapper = new LambdaQueryWrapper<>();

        if(!StringUtils.isEmpty(username)){
            wrapper.eq(Admin::getUsername,username);
        }

        if(!StringUtils.isEmpty(name)){
            wrapper.like(Admin::getName,name);
        }

        //调用方法实现条件分页查询
        IPage<Admin> pageModel = baseMapper.selectPage(pageParam,wrapper);
        return pageModel;
    }
}
